<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul id="posts"></ul>
    <script>
        // 前端 通过fetch 去和后端通信
        // 前端取数据的API
        fetch('http://localhost:3000/posts')
            .then(data=>data.json())
            .then(data=>{
                console.log(data,'////')
                document.getElementById('posts')
                    .innerHTML=data.map(post=>`
                        <li>
                            ${post.id} ${post.title} ${post.author}
                        </li>
                    `).join('')
                console.log(data);
            })
    </script>
</body>
</html>